package com.eclipse.e0112_多线程.考试_三线程读取文件;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;

/*
 * 写线程类 读取文件内容 打印出来
 * 启动3个线程
 */
public class 三线程读取文件 {
	
	
	public static void main(String[] args) {
		A a = new A();
		a.start();
		
		B b = new B();
		b.start();
		
		C c = new C();
		c.start();
	}
	
	
}

class A extends Thread{
	public void run() {
		List<String> lines = null;
		try {
			lines = Files.readAllLines(Paths.get("/Users/liuzhuangzhuang/test/a.txt"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		for (String line : lines) {
			System.out.println(line+"1");
		}
	}
	
}

class B extends Thread{
	public void run() {
		List<String> lines = null;
		try {
			lines = Files.readAllLines(Paths.get("/Users/liuzhuangzhuang/test/a.txt"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		for (String line : lines) {
			System.out.println(line+"2");
		}
	}
}

class C extends Thread{
	public void run() {
		List<String> lines = null;
		try {
			lines = Files.readAllLines(Paths.get("/Users/liuzhuangzhuang/test/a.txt"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		for (String line : lines) {
			System.out.println(line+"3");
		}
		
		
//		while(!lines.isEmpty()) {
//			System.out.println(lines.get(0));
//		}
	}
}